home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
ldb.zip
/
CBDRDEM1.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
2KB
|
92 lines
// cbdrdem1.cpp
// Demo CBinder for fixed size data.
// Link with binder.obj, sbinder.obj, cbinder.obj
#include <fstream.h>
#include <iomanip.h>
#include "cbinder.hpp"
#define ID_CBDR_INTCMP 1
main()
{
CBinder B(sizeof(unsigned),5);
CBinder::registerClass();
for (unsigned i = 0;B.pushCLN(&i); i++);
cout << "\n\nCBinder Stack of cloned "
"unsigned integers:\n\n";
while (B++)
cout << "node: " << setw(6)
<< B.CurNode()
<< " contents: "
<< *(int *)(voiD)B << endl;
B.setCurNode(3);
B.link();
cout << "\n\nCurNode: " << B.CurNode()
<< " contains: "
<< *(int *)(voiD)B
<< endl << endl;
ofstream oS("cbdrdem1.txt");
if (oS) {
oS << (StreamablE) B;
B.restream();
oS.close();
ifstream iS("cbdrdem1.txt");
if (iS) {
StreamablE C;
iS >> C;
iS.close();
RestreamRegistry();
if (C)
{ //***
cout << "\n\nStreamed and"
<< " reloaded CBinder "
<< "of cloned integers\n\n";
cout << "CurNode recorded in "
<< "stream and reloaded: "
<< ((CBindeR)C)->CurNode()
<< " contains: "
<< *(int *)(voiD)*(CBindeR)C
<< endl << endl;
for (((CBindeR)C)->setCurNode();
(*(CBindeR)C)++;
cout << "node: "
<< setw(6)
<< ((CBindeR)C)
->CurNode()
<< " contents: "
<< *(int *)(voiD)
*(CBindeR)C
<< endl);
delete (CBindeR) C;
} //***
else
cout << "\n\nUnable to "
<< "reload"
<< " CBinder \n\n";
}
else
cout << "\n\nUnable to "
<< "reopen"
<< " stream for input of"
<< " of CBinder \n\n";
}
B.unlink();
return 0;
}